home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
prime.fac
< prev
next >
Wrap
Text File
|
1995-03-23
|
6KB
|
234 lines
Article 3018 of comp.sys.handhelds:
Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!uunet!mcsun!unido!fauern!fauern!faui1f!kskalb
From: kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb)
Newsgroups: comp.sys.handhelds
Subject: HP48: Factoring Integers
Message-ID: <kskalb.661793814@faui1f>
Date: 21 Dec 90 15:36:54 GMT
Sender: root@medusainformatik.uni-erlangen.de
Lines: 221
Hello,
This routine factors integers into primes.
The program does trial division by all numbers that
are not true multiples of 2,3,5 or 7.
The main work is done in mcode, so it is fast.
You need ASC\-> to install it.
Happy Christmas and a merry new year,
-KK
---------------------------------------------------------------------
Author
---------------------------------------------------------------------
Mail any suggestions or comments to
kskalb@informatik.uni-erlangen.de
---------------------------------------------------------------------
Usage
---------------------------------------------------------------------
Input:
Level 2: Number n to be factored (binary or real; n < 2^63)
Level 1: Bound b (binary or real; b < 2^20)
Output:
Level 1: List of Factors
If the program is sure that all numbers in the output list are indeed
primes, the list will be tagged with a plus-sign.
If the tag is missing, the last entry in the list might not be a prime.
All divisors t of n with t<=b will be found.
The entries in the result will be real, unless they are greate then 2^39.
Note that this can only happen to the last number in the list.
---------------------------------------------------------------------
Installation
---------------------------------------------------------------------
-- Download the following program to your HP48.
-- Be sure that ASC/-> is accessible.
-- Evaluate the downloaded object.
-- A program named 'TRIAL' will appear on the current directory.
---------------------------------------------------------------------
Warning
---------------------------------------------------------------------
The program 'TRIAL' contains a code object.
To my knowledge, programs containing code object can't be
edited on the HP48 by standard means, so don't try it.
---------------------------------------------------------------------
Disclaimer
---------------------------------------------------------------------
This program makes use of undocumented low-level features of
the HP48SX calculator, and may or may not cause loss of data,
excessive battery drainage, and/or damage to the calculator
hardware. The Author takes no responsibility whatsoever for
any damage caused by the use of this program.
This software is provided "as is" and WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, including, but not limited to, THE IMPLIED
WARRANTIES OF MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE.
------------------------------------------------------------------------------
Klaus Kalb | mail : IMMD1 / Martenstr. 3 / W-8520 Erlangen / Germany
| email: kskalb@immd1.informatik.uni-erlangen.de
------------------------------------------------------------------------------
%%HP: T(3)A(R)F(,);
@
@ TRIAL (generated by hp48pack at 21.12.90)
@
@$NAME TRIAL
@$DATE 21.12.90
@$VERSION 2.18
@
@
@ UserTrial 2.02 11.12.90
@ CodeTrial 1.00 21.12.90
@ Install 2.00 21.12.90
@ TRIAL 2.00 21.12.90
@
@
\<< CLLCD
"----------------------" DUP 1 DISP
"TRIAL 2.18 21.12.90" 2 DISP
DUP 3 DISP
" Factoring by a Wheel" 4 DISP
" by Klaus Kalb" 5 DISP
6 DISP
\<<
@ $NAME UserTrial
@ $DATE 11.12.90
@ $VERSION 2.02
\<<
\-> n b
\<<
IFERR
IF n TYPE DUP 0 \=/ SWAP 10 \=/ AND THEN 514 DOERR END
IF b TYPE DUP 0 \=/ SWAP 10 \=/ AND THEN 514 DOERR END
IF n #0d + DUP #7FFFFFFFFFFFFFFFh > SWAP #0d == OR THEN 515 DOERR END
IF b #0d + #FFFFFh > THEN 515 DOERR END
THEN
IF -55 FC? THEN n b END
ERRN DOERR
END
n #0d +
b #0d +
CodeTrial
SWAP
#18DBFh SYSEVAL @ Short to Real
\-> r k
\<<
IF k THEN
1 k START
#18DBFh SYSEVAL
k ROLL
NEXT
END
k \->LIST
IF r #1d > THEN
r
IF
DUP DUP B\->R R\->B ==
THEN
B\->R
END
+
END
IF b #1d + DUP * r > THEN "+" \->TAG END
\>>
\>>
\>>
@ $END UserTrial
'UserTrial' STO
@ $NAME CodeTrial
@ $DATE 21.12.90
@ $VERSION 1.00
@ $COMMAND ASC\->
"CCD20B61008F77F3510110AAF210810B2081B58082444000C213665702424626
42466264264684242486462462664246264242A2A021224011BD2BF6BF6BF6BF
6BF6BF61088F2D7608F735608FB97601112F8DD6950AF015A097CB12081B5808
24C7FFFC21366EDF118C24A91081181129F2C8111118AF3AF19F262A76B779FE
7F81EA75A7F9F280B7AB7597F9E11A9F180AF910A97CD3AF4101113132AF2263
01A7A103208F2D7608F735608FB9760113130657F1606E3F2485"
@ $END CodeTrial
ASC\->
'CodeTrial' STO
@ $NAME Install
@ $DATE 21.12.90
@ $VERSION 2.00
\<<
'UserTrial' RCL
#054AFh SYSEVAL @ PRG\->
#05459h SYSEVAL @ \->LIST
DUP 'CodeTrial' POS
SWAP SIZE
SWAP - 2 + \-> n
\<<
'UserTrial' RCL #054AFh SYSEVAL
n ROLL
DROP 'CodeTrial' RCL
n ROLLD
\>>
#05445h SYSEVAL @ \->PRG
\>>
@ $END Install
'Install' STO
@ $NAME TRIAL
@ $DATE 21.12.90
@ $VERSION 2.00
@ $COMMAND EVAL
\<<
Install
{ 'UserTrial' 'CodeTrial' 'Install' } PURGE
\>>
@ $END TRIAL
EVAL
'TRIAL' STO
\>>
" unpack ?" 7 DISP
@
{ { "YES" \<< EVAL
" TRIAL installed." 7 DISP 3 FREEZE
0 MENU \>> }
"" "" "" ""
{ "NO" \<< DROP
0 MENU \>> }
} 3 FREEZE TMENU \>>
@$END TRIAL
@ END END END END END END END END END END END END END END END END END END